<template>
    <el-menu
            background-color="#79925f"
            text-color="#fff"
            active-text-color="#ffd04b"
            style="text-align: left"
            :default-active="defaultActive"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @select="handleSelect"
            @close="handleClose">
        <el-submenu index="1">
            <template slot="title">
                <i class="el-icon-location"></i>
                <span>markdown</span>
            </template>
            <el-menu-item index="quill">
                <i class="el-icon-menu"></i>
                <span slot="title">quill编辑器</span>
            </el-menu-item>
        </el-submenu>

        <el-submenu index="2">
            <template slot="title">
                <i class="el-icon-location"></i>
                <span>echarts</span>
            </template>
            <el-menu-item index="echart">
                <i class="el-icon-menu"></i>
                <span slot="title">echart</span>
            </el-menu-item>
            <el-menu-item index="echart-dynamic">
                <i class="el-icon-menu"></i>
                <span slot="title">echart-dynamic</span>
            </el-menu-item>
        </el-submenu>

        <el-submenu index="3">
            <template slot="title">
                <i class="el-icon-location"></i>
                <span>table</span>
            </template>
            <el-menu-item index="simple">
                <i class="el-icon-menu"></i>
                <span slot="title">simple</span>
            </el-menu-item>
        </el-submenu>
    </el-menu>
</template>

<script>
    export default {
        name: "index",
        data(){
          return {
              defaultActive: ''
          }
        },
        methods: {
            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleSelect(key) {
                if (this.$route.name !== key){
                    this.$router.push({name: key})
                }
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },
            setDefault(){
                this.defaultActive = this.$route.name
            }
        },
        mounted() {
            this.setDefault()
        },
        watch: {
            $route() {
                this.setDefault()
            }
        }
    }
</script>

<style scoped>
   >>> .el-submenu__title i{
        color: #a8bf8f !important;
    }
    >>> .el-menu-item i{
        color: #a8bf8f ;
    }
</style>
